// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
"use strict";

chrome.alarms.onAlarm.addListener(() => {
  chrome.action.setBadgeText({ text: "" });
  chrome.notifications.create({
    type: "basic",
    iconUrl: "stay_hydrated.png",
    title: "Time to Hydrate",
    message: "Everyday I'm Guzzlin'!",
    buttons: [{ title: "Keep it Flowing." }],
    priority: 0,
  });
});

chrome.notifications.onButtonClicked.addListener(async () => {
  const item = await chrome.storage.sync.get(["minutes"]);
  chrome.action.setBadgeText({ text: "ON" });
  chrome.alarms.create({ delayInMinutes: item.minutes });
});
// chrome.action.onClicked.addListener(async (e) => {
//   console.log("点击了扩展图标");
//   // 获取当前窗口信息
//   const currentWindow = await chrome.windows.getCurrent();
//   const screenWidth = currentWindow.width;
//   const screenHeight = currentWindow.height;
//   chrome.windows.create({
//     url: chrome.runtime.getURL("popup.html"),
//     type: "popup",
//     width: 500,
//     height: screenHeight,
//     left: screenWidth - 510, // 距离屏幕左侧距离
//     top: 30, // 距离屏幕顶部距离
//   });
// });
